package com.bw.kf.all2211a.fg.fgviewModel

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.ToastUtils
import com.bw.kf.all2211a.R
import com.bw.kf.all2211a.databinding.ActivityResetBinding
import com.bw.kf.mvvm.base.BaseActivity
@Route(path = "/app/fg/fgviewModel/ResetActivity")
class ResetActivity : BaseActivity<ActivityResetBinding, ResetViewMode>() {
    override fun iniView() {
        binding.getCode.setOnClickListener {
            viewModel.sendCode(SPUtils.getInstance().getString("phone"))
        }
     binding.reset.setOnClickListener {
         viewModel.getReset(SPUtils.getInstance().getString("phone"),binding.code.text.toString(),binding.password.text.toString())
     }

    }
    override fun iniData() {
        viewModel.success.observe(this){
            if (it.code==200){
                ToastUtils.showLong("重置成功")
                finish()
            }
            ToastUtils.showLong(it.message)
        }
        viewModel.successC.observe(this){
            if(it.code==200){
                binding.code.setText(it.data.content.substring(8,14))
            }
            ToastUtils.showLong(it.message)
        }
    }
    override fun getViewModel(): Class<ResetViewMode> {
        return ResetViewMode::class.java
    }

    override fun Layoutid()=R.layout.activity_reset
}